home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS15.ADF / C / Ask.c next >
C/C++ Source or Header  |  1988-04-20  |  2KB  |  67 lines

  1. /********************************************************
  2.  *  ASK: For use in a batch file to ask a question for  *
  3.  *       branching purposes.  Simple command line parse *
  4.  *       with a switch case searching for key negatives *
  5.  *       and exiting with error lever 5 (warning) if    *
  6.  *       found, error level 0 if not found.  Negatives  *
  7.  *       include 0,f F,n,N.  This is public domain, but *
  8.  *       inquiries are welcome.  See the confess()      *
  9.  *       function below, or reach me thru CIS 71725,745 *
  10.  *       The Well: RSVP, or GEnie: Jim.Thomas           *
  11.  ********************************************************/ 
  12.                              
  13.                           
  14. #include <stdio.h>
  15.  
  16. main (argc,argv)       /*ASK:  Returns error level upon response*/
  17. int argc;
  18. char *argv[];
  19.  
  20. {
  21.  
  22.   int failat,i;
  23.   char c;
  24.  
  25.   failat = 0;
  26.  
  27.   if (argc == 1)
  28.   {
  29.    printf("Usage: %s <string>\n\n", argv[0]);
  30.    confess();
  31.   }
  32.  
  33.   for (i = 1; i < argc; i++)
  34.    printf("\033[2m%s\033[0m ",argv[i]);
  35.  
  36.   while ((c = getchar()) == NULL);
  37.  
  38.   switch(c)
  39.   {
  40.    case '0':
  41.    case 'n':
  42.    case 'N':
  43.    case 'f':
  44.    case 'F':
  45.     failat = 5;
  46.     break;
  47.    default:
  48.     failat = 0;
  49.     break;
  50.   }
  51.   while ((c = getchar()) != '\n');
  52.   exit(failat);
  53. }
  54.  
  55. confess()  /*Are you going to talk?  Or do we have to beat it out of you?*/
  56. {
  57.   printf("                 Support your local Amiga Users Group\n\n");
  58.   printf("   This program is provided as public domain for Amiga users.\n");
  59.   printf("   Written by Jim Thomas, an AUGgie doggie.  For information:\n\n");
  60.   printf("                              AUGment\n");
  61.   printf("                           P.O. Box 1863\n");
  62.   printf("                      Fremont, CA  94538-0186\n\n");
  63.   printf("                    AUGment BBS: (415) 659-9169\n\n");
  64.   printf("                 AUGment Hot line: (415) 651-1160\n\n");
  65.   exit(0);
  66. }
  67.